<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>下载管理-上传文件</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" href="../../static/css/font.css">
		<link rel="stylesheet" href="../../static/css/weadmin.css">
		<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
		<!--[if lt IE 9]>
	      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
	      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
	    <![endif]-->
	</head>

	<style>
		.labelContainer{
			display: flex;
			flex-direction: row;
			align-items: center;
			justify-content: flex-start;
		}
	</style>
	<script>
        function init() {
            var id = JSON.parse(localStorage.getItem("user"));
            $("#id").val(id.uid);
        }
	</script>
	<body onload="init()">
	<div class="weadmin-nav">
			<span class="layui-breadcrumb">
				<a href="">首页</a>
				<a href="">上传文档</a>
				<a>
					<cite>上传文档</cite>
				</a>
			</span>
	</div>
	<div class="weadmin-body">
		<form class="layui-form">
			<div class="layui-input-inline">
				<input type="hidden" id="id"  autocomplete="off" class="layui-input createBy">
			</div>
			<div class="layui-form-item">
					<label for="username" class="layui-form-label">
						<span class="we-red">*</span>文档标题
					</label>
					<div class="layui-input-inline">
						<input type="text" id="username" name="title" required="" lay-verify="required" autocomplete="off" class="layui-input title">
					</div>
				</div>
			<div class="layui-form-item">
				<label for="username" class="layui-form-label">
					<span class="we-red">*</span>文档描述
				</label>
				<div class="layui-input-inline">
					<textarea name="content" required lay-verify="required" placeholder="请输入" class="layui-textarea content" style="width: 600px;height: 300px;"></textarea>
				</div>
			</div>
			<div class="layui-form-item">
					<label for="username" class="layui-form-label">
						<span class="we-red">*</span>文档:
					</label>
				<button type="button" class="layui-btn" id="test1">
					<i class="layui-icon">&#xe67c;</i>上传文件
				</button>
			</div>
			<div class="layui-form-item">
				<div class="layui-inline labelContainer">
					<label for="username" class="layui-form-label">
						有效时间
					</label>
					<input class="layui-input activeTime" style="width: 200px" placeholder="截止日" name="activeTime" id="end">
				</div>
			</div>
			<div class="layui-form-item">
				<label for="username" class="layui-form-label">
				</label>
				<button class="layui-btn" id="addDocument">上传</button>
			</div>
		</form>
	</div>
	<script src="../../lib/layui/layui.all.js" charset="utf-8"></script>
	<script src="../../static/js/jquery.1.11.3.min.js"></script>
	<script src="../../static/js/util/util.js"></script>
	<script src="../../static/js/eleDel.js" type="text/javascript" charset="utf-8"></script>
	<script>
        layui.use(['upload','form'], function () {
            var form = layui.form;
            var upload = layui.upload;
            //创建一个上传组件
            upload.render({
                elem: '#test1'
                , url: '/document/upload'
                , done: function (res) { //上传后的回调
                    layer.msg(JSON.stringify(res.data));
                }
                , accept: 'file' //允许上传的文件类型
            });
            $("#addDocument").click(function () {
                post('/document/addDocument', {
                    createBy: $(".createBy").val(),
                    title: $(".title").val(),
                    content: $(".content").val(),
                    activeTime:$(".activeTime").val()
                }, function (data) {
					alert(data);
                });
            });
        });
</script>

</body>

</html>